<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../utils/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<!-- 用事件绑定的方式去执行clicknow -->
			<element1 @clicknow="clicknow"></element1>
			
		</div>
		<script>
			Vue.component('element1',{
				props:['title'],
				data:function(){
					return {
						count:0
					}
				},
				template:'<button @click="clickfun" >you clicked me {{count}} times.</button>',
				methods:{
					clickfun:function(){
						this.count++;
						// this.$emit('事件名称',携带的参数);用emit方法触发了clicknow函数
						this.$emit('clicknow',this.count);
					}
				}
			})
			
			var vm = new Vue({
				el:'#app',
				data:{
					
				},
				methods:{
					clicknow:function(e){
						console.log(e)
					}
				}
			})
		</script>
	</body>
</html>
